package com.example.anew.journey.mynewjourney.firstchangelogic.firstChangeCardiacDetection.model;

import android.content.Context;
import android.content.SharedPreferences;

import com.example.anew.journey.mynewjourney.bean.ISFirstBean;
import com.example.anew.journey.mynewjourney.bean.TakeDateBean;

import static android.content.Context.MODE_PRIVATE;

/**
 * 杭州惟君医疗科技有限公司17
 * Created by 20433 on 2018/3/27
 *
 * @desc 东风山河绿，春已不折柳，繁花看不尽，处处惹人留
 * @desc 佛祖镇楼，bug辟容易
 */

public class FirstChangeCardiacDetectionModel implements ISFirstChangeCardiacDetectionModel {


    @Override
    public TakeDateBean TakeDate(Context mContext) {
        SharedPreferences sharedPreferences = mContext.getSharedPreferences("My_App_Cardiac", MODE_PRIVATE);
        String my_use_id = sharedPreferences.getString("my_use_id", "");
        String my_use_token = sharedPreferences.getString("my_use_token", "");
        TakeDateBean takeDateBean =  new TakeDateBean();
        takeDateBean.setUser_id(my_use_id);
        takeDateBean.setToken(my_use_token);
        return takeDateBean;
    }

    @Override
    public void SaveISFirstDate(ISFirstBean bean, Context mContext) {
        SharedPreferences sharedPreferences = mContext.getSharedPreferences("My_App_Cardiac", MODE_PRIVATE);
        SharedPreferences.Editor editor = sharedPreferences.edit();
        editor.putString("my_test_date",bean.getDatestr());
        editor.putString("my_test_result",bean.getResult());
        //保存key-value对到文件中
        editor.commit();

    }

    @Override
    public ISFirstBean TakeISFirstDate(Context mContext) {
        ISFirstBean bean =  new  ISFirstBean();
        SharedPreferences sharedPreferences = mContext.getSharedPreferences("My_App_Cardiac", MODE_PRIVATE);
        String my_test_date = sharedPreferences.getString("my_test_date","");
        String my_test_result =  sharedPreferences.getString("my_test_result","");
        bean.setDatestr(my_test_date);
        bean.setResult(my_test_result);
        return bean;
    }
}
